<?php
/**
 * @package   auto_occasion
 * @subpackage 
 * @author    CMS
 * @copyright  2011
 * @license    All rights reserved
 */

class fiabiliteSrv {

     /**
     * Fonction permettant de récupérer un essai à partir de l'id d'une gamme
     * @param int $IdGammeModele
     * @return object
     *
     */
    public function getByIdGammeModele ($IdGammeModele) {
        // instanciation de la factory
        $maFactory = jDao::get("commun~essai_fiabilite");
        

        return $maFactory->getByGammeModeleId($IdGammeModele)->fetch();
         

    }

     /**
     * Fonction permettant de sauvegarder les fiabilites
     * @return object $fiabilite
     *
     */
    public function ajouter ($fiabilite) {
        // instanciation de la factory
        $maFactory = jDao::get("commun~essai_fiabilite");
        $records   = jDao::createRecord("commun~essai_fiabilite");

        $records->ess_gammeModele_id = $fiabilite->ess_gammeModele_id;
        $records->name               = $fiabilite->name;
        $records->content            = $fiabilite->content;
        
        
        if ($maFactory->insert($records)) {
            return $records->fiabilite_id;
        }

    }
     /**
     * Fonction permettant de modifier les fiabilites
     * @return object $partenaire
     *
     */
    public function modifier ($fiabilite) {
        // instanciation de la factory
        $maFactory = jDao::get("commun~essai_fiabilite");
        $records   = $maFactory->get($fiabilite->fiabilite_id);

        $records->ess_gammeModele_id = $fiabilite->ess_gammeModele_id;
        $records->name               = $fiabilite->name;
        $records->content            = $fiabilite->content;
        

        if ($maFactory->update($records)) {
            return $fiabilite->fiabilite_id;
        }

    }

}